~ chicken-core (master) /manual/Module (scheme complex)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (scheme complex)
5
6
7R7RS Operations on complex numbers.
8
9
10<procedure>(make-rectangular x[1] x[2])</procedure><br>
11<procedure>(make-polar x[3] x[4])</procedure><br>
12<procedure>(real-part z)</procedure>
13<procedure>(imag-part z)</procedure>
14<procedure>(magnitude z)</procedure>
15<procedure>(angle z)</procedure>
16
17Let x[1], x[2], x[3] and x[4] be real numbers and z be a complex number such that
18
19 z = x[1] + x[2] * i = x[3] * e^(i * x[4])
20
21Then all of
22
23 (make-rectangular x[1] x[2]) ==> z
24 (make-polar x[3] x[4]) ==> z
25 (real-part z) ==> x[1]
26 (imag-part z) ==> x[2]
27 (magnitude z) ==> |x[3]|
28 (angle z) ==> x[angle]
29
30are true, where
31
32 −π ≤ x[angle] ≤ π with x[angle] = x[4] + 2 * π * n for some integer n.
33
34The make-polar procedure may return an inexact complex number even if its
35arguments are exact. The real-part and imag-part procedures may return exact
36real numbers when applied to an inexact complex number if the corresponding
37argument passed to make-rectangular was exact.
38
39Rationale: The magnitude procedure is the same as abs for a real argument,
40but abs is in the base library, whereas magnitude is in the optional
41complex library.
42
43---
44Previous: [[Module (scheme char)]]
45
46Next: [[Module (scheme cxr)]]